package com.zhaorui.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.zhaorui.aop.Annotation2;
import com.zhaorui.entity.GzMfMo;
import com.zhaorui.entity.GzTfJh;
import com.zhaorui.entity.ZR;
import com.zhaorui.form.JhQueryForm;
import com.zhaorui.mapper.GzMfMoMapper;
import com.zhaorui.service.GzMfMoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("moSearch")
@Slf4j
@CrossOrigin
@Api(tags = "MO管理")
public class MfMoController {
    @Autowired
    private GzMfMoService gzMfMoService;


    //手动更新
//    @PostMapping("/updateMfMo2/{moNo}")
//    @ApiOperation("手动更新")
//    @Annotation2(tableName = "updateMfMo2", optionName = "更新", primaryKeyName = "moNo")
//    public ZR updateMfMo2(@PathVariable String moNo) {
//        gzMfMoService.getById(moNo);
//        return new ZR(1000, "更新成功", "更新成功");
//    }

    //根据mo_no查询所有
    @GetMapping("/queryByMfMo/{moNo}")
    @ApiOperation("根据派工单moNo")
//    @Annotation2(tableName = "queryByMfMo", optionName = "查询")
    public ZR queryByMfMo(@PathVariable String moNo) {
        log.info("开始根据moNo查询:{}", moNo);
        GzMfMo gzMfMo = new GzMfMo();
        gzMfMo = gzMfMoService.queryByMfMo(moNo);
        return new ZR(1000, "查询成功", gzMfMo);

    }

    //修改
//    @Annotation2(tableName = "mfMo", optionName = "修改")
    @PutMapping("/modifyMfMo")
    @ApiOperation("修改")
    public ZR modifyMfMo(@RequestBody GzMfMo gzMfMo) {
        log.info("开始修改:{}", gzMfMo);
        gzMfMoService.updateById(gzMfMo);
        return new ZR(1000, "修改成功", gzMfMo);
    }
}
